﻿using System;

public class AlarmClock
{
    public event EventHandler Tick;
    public event EventHandler Alarm;

    private string alarmTime;

    public AlarmClock(string alarmTime)
    {
        this.alarmTime = alarmTime;
    }

    public void Start()
    {
        while (true)
        {
            // 模拟时钟嘀嗒
            System.Threading.Thread.Sleep(1000);

            // 触发嘀嗒事件
            Tick?.Invoke(this, EventArgs.Empty);

            // 判断是否到达闹钟设定时间
            if (DateTime.Now.ToString("HH:mm:ss") == alarmTime)
            {
                // 触发响铃事件
                Alarm?.Invoke(this, EventArgs.Empty);
                break;
            }
        }
    }
}